package com.bops.service;

import java.util.HashMap;
import java.util.List;

import com.bops.dal.user.dao.RenyuaninfoDAO;
import com.bops.dal.user.dataobject.RenyuaninfoDO;
import com.bops.dal.user.queryobject.UserQuery;

public class UserService {

    private RenyuaninfoDAO     renyuaninfoDAO;
    
    public UserService()
    {
        System.err.println("111111");
    }
    

    public void setRenyuaninfoDAO(RenyuaninfoDAO renyuaninfoDAO) {
        this.renyuaninfoDAO = renyuaninfoDAO;
    }

    public void insertRenyuaninfo(RenyuaninfoDO record) {
        renyuaninfoDAO.insert(record);
    }

    public static boolean isNotEmpty(String s) {
        if (s != null && s.trim().length() > 0) {
            return true;
        }
        return false;
    }

    /**
     * 计算实际返回的每页数
     * 
     * @param pagesize 计划每页数
     * @param pageRecordCount 最后取多少记录
     * @param count 总记录
     * @return
     */
    public static int calcPageSize(int pagesize, int pageRecordCount, int count) {
        if (count > pageRecordCount) {
            return pagesize;
        }
        int index = count - (pageRecordCount - pagesize);
        return index > 0 ? index : 0;
    }

    public List<RenyuaninfoDO> listWake(HashMap<String, Object> map) {
        return renyuaninfoDAO.listWake(map);
    }

    public List<RenyuaninfoDO> listRenyuaninfo(UserQuery queryUser) {
        return renyuaninfoDAO.listRenyuaninfo(queryUser);
    }

    public RenyuaninfoDO findRenyuaninfo(String engID) {
        UserQuery query = new UserQuery();
        query.setEngId(engID);
        List<RenyuaninfoDO> list = listRenyuaninfo(query);
        if (list == null || list.size() == 0) {
            return null;
        }
        return list.get(0);
    }
    
    public RenyuaninfoDO findUserinfo(String email) {
        UserQuery query = new UserQuery();
        query.setEmail(email);
        List<RenyuaninfoDO> list = listRenyuaninfo(query);
        if (list == null || list.size() == 0) {
            return null;
        }
        return list.get(0);
    }

    public int countRenyuaninfo(HashMap<String, Object> map) {
        return renyuaninfoDAO.countRenyuaninfo(map);
    }

    public int deleteByEngId(String engId) {
        return renyuaninfoDAO.deleteByEngId(engId);
    }

    public int updateRenyuaninfo(RenyuaninfoDO record) {
        return renyuaninfoDAO.updateRenyuaninfo(record);
    }

    


}
